import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:ytbusiness/config/icon_list.dart';
import 'package:ytbusiness/utils/screen_adaptation.dart';


//选择银行
class ChoiceBank extends StatefulWidget {
  @override
  _ChoiceBankState createState() => _ChoiceBankState();
}

class _ChoiceBankState extends State<ChoiceBank> {
  List<String> name = ["中国农业银行卡储蓄卡(4747)","中国农业银行卡储蓄卡(4747)","中国农业银行卡储蓄卡(4747)","农商银行(4545)"];
  List<String> iconList = [IconList.agriculturalBank,IconList.agriculturalBank,IconList.agriculturalBank,IconList.bankOfAgricultureAndCommerce];
  int checkPay = 0;//选择支付方式
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        elevation:0.5,
        centerTitle: false,
        backgroundColor: Colors.white,
        title: Text("选择开户行",style: TextStyle(color: Color(0xff323232),fontSize: setSp(18),fontWeight: FontWeight.w600),maxLines: 1,overflow: TextOverflow.ellipsis,),
        leading: GestureDetector(
          behavior: HitTestBehavior.opaque,
          onTap: (){
            Navigator.pop(context);
          },
          child: Row(
            children: [
              Container(
                  margin: EdgeInsets.only(left: setWidth(15)),
                  width: setWidth(10),
                  height: setWidth(17),
                  child: Image.asset("assets/images/return.png",fit: BoxFit.cover,)
              ),
            ],
          ),
        ),
      ),
      body: Container(
        margin: EdgeInsets.only(top: setWidth(12)),
        child:ListView.builder(
            physics: NeverScrollableScrollPhysics(),
            shrinkWrap: true,
            itemCount: name.length,
            itemBuilder: (context,index){
              return GestureDetector(
                behavior: HitTestBehavior.opaque,
                onTap: (){
                  setState(() {
                    checkPay = index;
                  });
                  Navigator.pop(context,{"name" :name[index],"image" :iconList[index]});
                },
                child: Column(
                  children: [
                    Container(
                      color: Colors.white,
                      padding: EdgeInsets.only(left: setWidth(21),right: setWidth(21),top: setWidth(17),bottom: setWidth(17)),
                      child: Row(
                        mainAxisAlignment: MainAxisAlignment.spaceBetween,
                        children: [
                          Row(
                            children: [
                              Container(
                                child: Image.asset(iconList[index],fit: BoxFit.cover,),
                                width: setWidth(25),
                                height: setWidth(25),
                              ),
                              SizedBox(
                                width: setWidth(18),
                              ),
                              Container(
                                child: Text(name[index],style: TextStyle(color: Color(0xff323232),fontSize: setSp(16)),),
                              )
                            ],
                          ),
                          checkPay != index ?Container(): Container(
                            child: Image.asset("assets/images/check_pay.png",fit: BoxFit.cover,),
                            width: setWidth(17),
                            height: setWidth(17),
                          ),
                        ],
                      ),
                    ),
                    Container(
                      margin: EdgeInsets.only(left: setWidth(67)),
                      height: setWidth(0.5),
                      color: Color(0xffF0F0F0),
                    ),
                  ],
                ),
              );
            })
      ),
    );
  }
}
